package com.zkingsoft.actions.admin;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.anotations.RemoveRequestToken;
import com.zkingsoft.anotations.SaveRequestToken;
import com.zkingsoft.constance.Dictionary;
import com.zkingsoft.model.BugTotal;
import com.zkingsoft.model.ReportTest;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.plugin.util.WebUtil;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.ReportTestService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-11-09 14:37
 */
@Controller
@RequestMapping(value = "admin/reportTest")
public class ReportTestController extends BaseController{

	@Resource
	private ReportTestService currentService;
	
	/**
	 * 列表显示
	 */
	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(ReportTest reportTest, PaginationVO pageVo) {
		return showList(currentService, reportTest, pageVo);
	}
   	
	/**
	 * 新增或者修改页面
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value = "/addOrModify")
	public @ResponseBody AjaxResult addOrModify(ReportTest reportTest) {
		if (reportTest.getId() != null) {
			return modify(currentService, reportTest, "测试报告");
		} else {
			// 新增的bug状态为待解决
			reportTest.setCreateTime(new Date());
			reportTest.setCreateUserId(getMe().getId());
			return add(currentService, reportTest, "测试报告");
		}
	}
	
   	/**
	 * 进入修改界面
	 */   
	@SaveRequestToken
   	@RequestMapping(value = "/editForm")
	public String editForm(Long id,Long projId) {
		ReportTest reportTest;
		if (id != null) {
			reportTest = currentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", reportTest);
		}
		List <BugTotal> list=currentService.userBugsDetail(projId);
		WebUtil.getRequest().setAttribute("list", list);
		return "admin/reportTest-form";
	}
   	
   	
   	/**
	 * 删除
	 */  
 	@RequestMapping(value = "/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(currentService, keys);
	}
  
 	
	/**
	 * 删除
	 */  
 	@RequestMapping(value = "/userBugsDetail")
	public @ResponseBody AjaxResult userBugsDetail(Long projId) {
 		List <BugTotal> list=currentService.userBugsDetail(projId);
		return new AjaxResult(AjaxResult.STATUS_OK, null, null, list, 0);
	}
 	
	/**
	 * 进入修改界面
	 */   
   	@RequestMapping(value = "/showTestReport")
	public String showTestReport(Long id) {
		 ReportTest reportTest;
		reportTest = currentService.findById(id);
		WebUtil.getRequest().setAttribute("obj", reportTest);
		return "admin/reportTest-look";
	}
 	
}